package com.zqxq.lottery.common.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 苦智
 * @date 2018/11/5 17:18
 * @description
 * @ClassName HttpUtilsEx
 */
public class HttpUtilsEx {
    public static String getIpAddr(HttpServletRequest request) {
         String ip = request.getHeader("x-forwarded-for");
         if(null == ip || 0 == ip.length() || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("Proxy-Client-IP");
         }
         if(null == ip || 0 == ip.length() || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("WL-Proxy-Client-IP");
         }
         if(null == ip || 0 == ip.length() || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("X-Real-IP");
         }
         if(null == ip || 0 == ip.length() || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
         }
         return ip;
    }
}
